/**
 * 
 */
package model;

import javax.cim.CIMDataType;
import javax.cim.CIMProperty;


/**
 * This abstract class represent an object that can be stored in a CIMServer.
 * @author alith
 */
public abstract class CIMObject {
	
	/**
	 * Register the CIM Object into the CIMServer
	 * @throws Exception this exception can be: <br>
	 *  -> a WBEMException - If the operation is unsuccessful, one of the following status code  will be included:<br>
     *     CIM_ERR_ACCESS_DENIED<br>
     *     CIM_ERR_NOT_SUPPORTED (provider does not support this method)<br>
     *     CIM_ERR_INVALID_NAMESPACE<br>
     *     CIM_ERR_INVALID_PARAMETER (for this method)<br>
     *     CIM_ERR_INVALID_CLASS (in this namespace)<br>
     *     CIM_ERR_ALREADY_EXISTS<br>
     *     CIM_ERR_FAILED (some other unspecified error occurred)<br>
     *     <br>
     *  -> an IllegalArgumentException - If the object has not all the required parameters (null).. during the creation of the
     *  instance object (on the client computer)
     */
	public abstract void register() throws Exception;
	
	/**
	 * Modify the object on the pegasus server (attempts to update with the new values)
	 * @throws Exception this exception can be: <br>
	 *  -> a WBEMException - If the operation is unsuccessful, one of the following status code will be included:<br>
 	 *     CIM_ERR_ACCESS_DENIED<br>
	 *     CIM_ERR_NOT_SUPPORTED (provider does not support this method)<br>
 	 *     CIM_ERR_INVALID_NAMESPACE<br>
	 *     CIM_ERR_INVALID_PARAMETER (for this method)<br>
 	 *     CIM_ERR_INVALID_CLASS (in this namespace)<br>
 	 *     CIM_ERR_NOT_FOUND (if instance does not exist)<br>
	 *     CIM_ERR_NO_SUCH_PROPERTY (in this instance)<br>
 	 *     CIM_ERR_FAILED (some other unspecified error occurred)<br>
 	 *<br>
 	 *  -> an IllegalArgumentException - If the object has not all the required parameters (null).. during the creation of the
     *  instance object (on the client computer) 
	 */
	public abstract void modify() throws Exception;
	
	/**
	 * Attempt to delete this object from the CIM Server (openpegasus)
	 * @throws Exception this exception can be: <br>
	 *  -> a WBEMException - If the operation is unsuccessful, one of the following status code will be included:<br>
     *    CIM_ERR_ACCESS_DENIED<br>
     *    CIM_ERR_NOT_SUPPORTED (provider does not support this method)<br>
     *    CIM_ERR_INVALID_NAMESPACE<br>
     *    CIM_ERR_INVALID_PARAMETER (for this method)<br>
     *    CIM_ERR_INVALID_CLASS (in this namespace)<br>
     *    CIM_ERR_NOT_FOUND (if the instance does not exist)<br>
     *    CIM_ERR_FAILED (some other unspecified error occurred)<br>
 	 *<br>
 	 *  -> an IllegalArgumentException - If the object has not all the required parameters (null).. during the creation of the
     *  instance object (on the client computer) 
	 */
	public abstract void delete() throws Exception;
	
	/**
	 * @deprecated
	 */
	protected String getStringValue(CIMProperty<String> prop) throws Exception{
		if (prop.getDataType().getType() == CIMDataType.STRING) throw new Exception("cette propriété n'est pas un string!");
		return prop.getValue();
	}
	
	/**
	 * @deprecated
	 */
	protected int getIntValue(CIMProperty<Integer> prop) throws Exception{
		if (prop.getDataType().getType() == CIMDataType.SINT32) throw new Exception("cette propriété n'est pas un int!");
		return prop.getValue();
	}
}